<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div{
            width: 100px;
            height: 200px;
            border: solid 1px #000;
        }
    </style>
</head>
<body>
    
    <button class="but">点击1</button>
    <button class="but1">点击2</button>
    <button class="but2">点击3</button>
    <script>
        var but=document.querySelector('.but');
        var but1=document.querySelector('.but1');
        var but2=document.querySelector('.but2');
        but.onclick=function(){
            // alert('这是一个弹窗')
            var aa=document.createElement('div');
            aa.innerHTML=`
                <p>点击确定关闭</p>
                <span class='qd'>确定</span>
            `

            document.body.appendChild(aa);

            var qd=document.querySelector('div .qd');
            qd.onclick=function(){
                qd.parentNode.remove();
            }
        }
        but1.onclick=function(){
        //    var a= prompt('请输入你的名字!');
            // console.log(a)
            var aa=document.createElement('div');
            aa.innerHTML=`
                <input type="text" class='w'>
                <span class='qd'>确定</span>
                <span class='qx'>取消</span>
            `

            document.body.appendChild(aa);

            var qd=document.querySelector('div .qd');
            var qx=document.querySelector('div .qx');
            var w=document.querySelector('div .w')
            qd.onclick=function(){
               console.log(qd.previousElementSibling.Value)
            }
        }
        but2.onclick=function(){
           var e= confirm('是否要删除按钮3');
           if(e){
               but2.remove();
           } 
        }
    </script>
</body>
</html>